package com.rabbbit.demo.dlx;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;


@Profile(value = "dlx")
@Configuration
public class RabbitMQDLXConfig {

    @Bean
    public Queue dlxQueue(){
        return new Queue("dlx.queue");
    }

    @Bean
    public DirectExchange dlxDirectExchange(){
        return new DirectExchange("dlx.direct.exchange");
    }

    @Bean
    public Binding dlxBinding(){
        return BindingBuilder.bind(dlxQueue()).to(dlxDirectExchange()).withQueueName();
    }

    @Profile(value="sender")
    @Bean
    public Sender sender(){
        return new Sender();
    }

    @Profile(value="receiver")
    @Bean
    public Receiver receiver(){
        return new Receiver();
    }
}
